<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"
	language="java"%>

<%@ taglib uri="/struts-tags" prefix="s"%>
<h2>Danh sách thư</h2>
<div class="list-table">
	<table id="ver-zebra">
		<colgroup>
			<col class="vzebra-odd" />
			<col class="vzebra-even" />
			<col class="vzebra-odd" />
			<col class="vzebra-even" />
			<col class="vzebra-odd" />
			<col class="vzebra-even" />
			<col class="vzebra-odd" />
			<col class="vzebra-even" />
		</colgroup>
		<thead>
			<tr>
				<th scope="col" id="vzebra-adventure">Tên sân</th>
				<th scope="col" id="vzebra-adventure">Quận</th>
				<th scope="col" id="vzebra-adventure">Địa chỉ</th>
				<th scope="col" id="vzebra-adventure">Người quản lý</th>
				<th scope="col" id="vzebra-adventure">Xác nhận</th>
			</tr>
		</thead>
		<tbody>
			<s:if test="%{listSoccerField.isEmpty()}">
				<tr>
					<td colspan="8">Chưa có dữ liệu</td>
				</tr>
			</s:if>
			<s:else>
				<s:iterator value="listSoccerField">
					<tr>
						<td><s:property value="name" /></td>
						<td><s:property value="district" /></td>
						<td><s:property value="address" /></td>
						<td><s:property value="owner.name" /></td>
						<td><s:if test="delete">
            					Đã bị hủy
            				</s:if> <s:elseif test="status">
            					Đã xác nhận
            				</s:elseif> <s:else>
								<input type="button" value="Đồng ý"
									onclick="acceptField(<s:property value='id' />)">
								<input type="button" value="Hủy"
									onclick="denyField(<s:property value='id' />)">
							</s:else></td>
					</tr>
				</s:iterator>
			</s:else>
		</tbody>
	</table>
</div>

<script type="text/javascript">
function goBack() {
	var url = 'mailbox';
	window.location.href = url;
}

function acceptField(id) {
	var datastr = 'id=' + id;
	$.ajax({
		type : "POST",
		url : "acceptSoccerField",
		data : datastr,
		cache : false,
		dataType : 'text',
		beforeSend : function() {
			$.blockUI({
				css : {
					border : 'none',
					padding : '15px',
					backgroundColor : '#000',
					'-webkit-border-radius' : '10px',
					'-moz-border-radius' : '10px',
					opacity : .5,
					color : '#fff'
				}
			});
		},
		complete : function() {
			$.unblockUI();
		},
		success : function(html) {
			goBack();
		}
	});
	
	return false;
}

function denyField(id) {
	var datastr = 'id=' + id;
	$.ajax({
		type : "POST",
		url : "denySoccerField",
		data : datastr,
		cache : false,
		dataType : 'text',
		beforeSend : function() {
			$.blockUI({
				css : {
					border : 'none',
					padding : '15px',
					backgroundColor : '#000',
					'-webkit-border-radius' : '10px',
					'-moz-border-radius' : '10px',
					opacity : .5,
					color : '#fff'
				}
			});
		},
		complete : function() {
			$.unblockUI();
		},
		success : function(html) {
			goBack();
		}
	});
}
</script>